package com.autosalon.model;

import java.io.Serializable;
import java.sql.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="OBJEDNAVKA")
public class Objednavka implements Serializable, IModelClass{
    
	@Id
	@GeneratedValue(strategy= GenerationType.AUTO)
	private Long id;
	
	@Column(name="DATUM", nullable=false)
	private Date datum;
	
	@Column(name="DODAT_INFORMACE", nullable=true, length=500)
	private String dodat_informace;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name = "ID_ZAKAZNIK")
	private Zakaznik customer;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name = "ID_SELLER")
	private Zakaznik seller;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name = "ID_FINANCOVANI")
	private Financovani financovani;	
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name = "ID_AUTOMOBILU")
	private Automobil automobil;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name = "ID_STAVU_OBJEDNAVKY")
	private StavObjednavky stav;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name = "ID_POISTENI")
	private Poisteni poisteni;
	
	@ManyToMany(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinTable(name = "PRIDANA_VYBAVA", 
				joinColumns={ 
								@JoinColumn(name = "ID_OBEDNAVKY") 
							}, 
				inverseJoinColumns={ 
								@JoinColumn(name = "ID_DOPLNKU")
								}
	)
	private List<Doplnek> pridanaVybava;

	@Override
	public Long getId() {
		return id;
	}

	public Zakaznik getCustomer() {
		return customer;
	}

	public void setCustomer(Zakaznik customer) {
		this.customer = customer;
	}

	public Zakaznik getSeller() {
		return seller;
	}

	public void setSeller(Zakaznik seller) {
		this.seller = seller;
	}

	public Financovani getFinancovani() {
		return financovani;
	}

	public void setFinancovani(Financovani financovani) {
		this.financovani = financovani;
	}

	public Automobil getAutomobil() {
		return automobil;
	}

	public void setAutomobil(Automobil automobil) {
		this.automobil = automobil;
	}

	public Date getDatum() {
		return datum;
	}

	public void setDatum(Date datum) {
		this.datum = datum;
	}

	public String getDodat_informace() {
		return dodat_informace;
	}

	public void setDodat_informace(String dodat_informace) {
		this.dodat_informace = dodat_informace;
	}

	public StavObjednavky getStav() {
		return stav;
	}

	public void setStav(StavObjednavky stav) {
		this.stav = stav;
	}

	public Poisteni getPoisteni() {
		return poisteni;
	}

	public void setPoisteni(Poisteni poisteni) {
		this.poisteni = poisteni;
	}

	public List<Doplnek> getPridanaVybava() {
		return pridanaVybava;
	}

	public void setPridanaVybava(List<Doplnek> pridanaVybava) {
		this.pridanaVybava = pridanaVybava;
	}
	
	
	
}
